from typing import List
class Solution:
    def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None:
        """
        Do not return anything, modify nums1 in-place instead.
        """
        # 双指针
        p1 = p2 = 0
        while p2 < n and p1 < m:
            print(p1, p2)
            if nums2[p2] > nums1[p1]:
                p1 += 1
            else:
                nums1.insert(p1, nums2[p2])
                p2 += 1
                p1 += 1
            
        while p2 < n :
            nums1.append(nums2[p2])
            print(nums2[p2])
            p2+=1

def test_a():
    nums1 = [1,3,4]
    nums2 = [0, 2,5,6]
    Solution().merge(nums1, len(nums1), nums2, len(nums2))
    assert  nums1 == [0,1,2,3,4,5,6]

def test_n_is_empty():
    nums1 = [1,3,4]
    nums2 = []
    Solution().merge(nums1, len(nums1), nums2, len(nums2))
    assert  nums1 == [1,3,4]


if __name__ == "__main__":
    nums1 = [1,3,4]
    nums2 = [0, 2,5,6]
    Solution().merge(nums1, len(nums1), nums2, len(nums2))

    print(nums1)
